package com.isdepci.project.carbon.controller;

import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.framework.web.page.TableDataInfo;
import com.isdepci.project.carbon.domain.BSulfurEmission;
import com.isdepci.project.carbon.domain.BSulfurEmissionParameter;
import com.isdepci.project.carbon.domain.param.WeatherDataExcel;
import com.isdepci.project.carbon.service.IBSulfurEmissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 脱硫排放Controller
 *
 * @author isdepci
 * @date 2025-03-29
 */
@RestController
@RequestMapping("/sulfur/emission")
public class BSulfurEmissionController extends BaseController
{
    @Autowired
    private IBSulfurEmissionService bSulfurEmissionService;


    /**
     * 查询脱硫剂类型查询参数
     */
    @GetMapping("/getSulfurEmissionParameters")
    public BSulfurEmissionParameter getSulfurEmissionParameters(@RequestParam Integer desulfurizerType) {
        return bSulfurEmissionService.getSulfurEmissionParameters(desulfurizerType);
    }

    /**
     * 脱硫排放计算
     */
    @GetMapping("/calSulfurEmission")
    public AjaxResult calSulfurEmission(@RequestParam Long projectId) {
        return bSulfurEmissionService.calSulfurEmission(projectId);
    }



    /**
     * 查询脱硫排放列表
     */
    //  @PreAuthorize("@ss.hasPermi('sulfur:emission:list')")
    @GetMapping("/list")
    public TableDataInfo list(BSulfurEmission bSulfurEmission)
    {
        startPage();
        List<BSulfurEmission> list = bSulfurEmissionService.selectBSulfurEmissionList(bSulfurEmission);
        return getDataTable(list);
    }

    /**
     * 导出脱硫排放列表
     */
    //  @PreAuthorize("@ss.hasPermi('sulfur:emission:export')")
    @Log(title = "脱硫排放", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BSulfurEmission bSulfurEmission)
    {
        List<BSulfurEmission> list = bSulfurEmissionService.selectBSulfurEmissionList(bSulfurEmission);
        ExcelUtil<BSulfurEmission> util = new ExcelUtil<BSulfurEmission>(BSulfurEmission.class);
        return util.exportExcel(list, "emission");
    }

    /**
     * 上传保存数据
     * @param excel
     * @return
     */
    @PostMapping("/changeData")
    public AjaxResult changeDataByProjectId(@RequestBody WeatherDataExcel excel) {
        return bSulfurEmissionService.changeDataByProjectId(excel);
    }


    /**
     * 获取脱硫排放详细信息
     */
    //  @PreAuthorize("@ss.hasPermi('sulfur:emission:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bSulfurEmissionService.selectBSulfurEmissionById(id));
    }

    /**
     * 新增脱硫排放
     */
    //  @PreAuthorize("@ss.hasPermi('sulfur:emission:add')")
    @Log(title = "脱硫排放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BSulfurEmission bSulfurEmission)
    {
        return toAjax(bSulfurEmissionService.insertBSulfurEmission(bSulfurEmission));
    }

    /**
     * 修改脱硫排放
     */
    //  @PreAuthorize("@ss.hasPermi('sulfur:emission:edit')")
    @Log(title = "脱硫排放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BSulfurEmission bSulfurEmission)
    {
        return toAjax(bSulfurEmissionService.updateBSulfurEmission(bSulfurEmission));
    }

    /**
     * 删除脱硫排放
     */
    //  @PreAuthorize("@ss.hasPermi('sulfur:emission:remove')")
    @Log(title = "脱硫排放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bSulfurEmissionService.deleteBSulfurEmissionByIds(ids));
    }
}
